home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / zs20b.zip / ZIP.H_ / ZIP.H
C/C++ Source or Header  |  1994-11-18  |  15KB  |  326 lines

  1. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2. // 
  3. //        Zip Studio 2.0 COPYRIGHT 1993, 1994 HEXANET - Written By Denis CHEVRON - All rights reserved
  4. //
  5. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  6. //
  7. //        Zip functions declarations header file for Basic and Basic like languages
  8. //
  9. //        To use the Zip VBX, put ZDLL20A.DLL, ZDLL20B.DLL and UZDLL20.DLL in your application directory
  10. //        or into the Windows/System directory.
  11. //        Also, don' t forget to redistribute the ZIPSTD20.VBX with your application...
  12. //
  13. //        If you choose the DLLs functions instead of the VBX interface:
  14. //              ->To Zip, Put ZDLL20A.DLL and ZDLL20B.DLL in the current dir and define _GOZIP.
  15. //        ->To UnZip, Put UZDLL20.DLL in the current dir and define _GOUNZIP.                               
  16. //
  17. //        The [2.0] means the routine is new.
  18. //
  19. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  20. #define _GOZIP            // to remove?
  21. #define _ZIP20
  22. #define _GOUNZIP        // to remove?
  23. #define _UNZIP20
  24.  
  25. #ifndef _zip_h
  26. #define _zip_h
  27.  
  28. #ifdef __cplusplus
  29. extern "C"
  30.     {
  31. #endif
  32.  
  33.  
  34. #ifdef _GOZIP
  35. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  36. //
  37. //        Zip functions
  38. //
  39. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  40.  
  41.  
  42. /* Errors constants */
  43. #define ZERROR_OK        0    // No error
  44. #define ZERROR_WARNING        1    // Just a warning (not an error)
  45. #define ZERROR_DESTFILE        2    // Destfile ( *.ZIP ) error
  46. #define ZERROR_INTERNAL     3    // Internal error
  47. #define ZERROR_FORMAT        4    // Not a Zip file
  48. #define ZERROR_NOMEM        5    // Not enough memory 
  49. #define ZERROR_NOFILE        6    // Nothing to do ( can be just a warning )
  50. #define ZERROR_NODLL        7    // Can' t find required DLLs
  51. #define ZERROR_COMMENT        8    // Comment missing or NULL
  52. #define ZERROR_NOCRYPT        9    // Can' t encrypt the files [2.0]
  53.  
  54. /* Overwrite mode */
  55. #define OVERWRITE_ALWAYS    0    // Always overwrite ( always zip files ) (default)
  56. #define OVERWRITE_NEVER        1     // Never overwrite
  57. #define OVERWRITE_PROMPT    2    // Ask the user
  58. #define OVERWRITE_UPDATE    3    // Overwrite if external file is newer
  59.  
  60.  
  61. /* Language mode ( for the replace dialog box )*/
  62. #define LANGUAGE_FRENCH        0    // French mode
  63. #define LANGUAGE_ENGLISH    1    // US Mode ( default )
  64. #define LANGUAGE_GERMAN        2    // German mode
  65. #define LANGUAGE_NONE        3    // No language (used with ZN_REPLACE) ** NEW! **
  66.  
  67.  
  68. /* More easy to use with AddFileToZip */
  69. #define STOREPATH_NO        0    // Don' t store paths
  70. #define STOREPATH_YES        1    // Store paths
  71. #define RECURSE_NO        0    // Don' t recurse sub dirs
  72. #define RECURSE_YES        1    // Recurse sub dirs
  73.  
  74.  
  75. /* Notification messages */
  76. #define ZN_ZIPPING        WM_USER + 46    // Zipping a file, WP = compressed size in K, LP = current file name
  77. #define ZN_FILEZIPPED        WM_USER + 45    // File is zipped, WP = compress rate, LP = file name
  78. #define ZN_WRITING        WM_USER + 48    // Replacing the Zip file, LP = zip file name
  79. #define ZN_DELETING        WM_USER + 47    // Deleting a file , LP = current file name
  80. #define ZN_REPARING        WM_USER + 49    // Reparing a Zip file, WP = (int)state
  81.                         //    step =  1 : Read / Write ,  LP = current file name
  82.                         //    step = 3 : Checking zip file, LP = zip file name
  83. #define ZN_COMPUTE        WM_USER + 52    // Before zip read, WP = zip files ( over 500, computing can be very long )
  84. #define ZN_REPLACE         WM_USER + 53    // The replace dialog box is opened
  85. #define ZN_ENCRYPT         WM_USER + 66    // Encrypt a file, WP= RATE, LP = filename [2.0]
  86. #define ZN_NETREAD        WM_USER + 67    // Reading a file from the network, WP = rate, LP = file name [2.0]
  87. #define ZN_NETWRITE        WM_USER + 68    // Writing the ZIP file to the network, WP = rate, LP = file name [2.0]
  88.  
  89.  
  90. /* Main functions */
  91. extern void WINAPI ZipInit( LPCSTR szYourName, LPCSTR szPassword );     // Init the Zip DLL
  92. extern int  WINAPI AddFileToZip( LPCSTR szZipFile, LPCSTR szMask, 
  93.                  int OverwriteMode, BOOL bStorePath,
  94.                  BOOL bRecurse, HWND hParentWnd, LPCSTR szPassword );    // Zip a file [2.0]
  95. extern int  WINAPI ZipDeleteFiles( LPCSTR szZipFile, LPCSTR szFiles, 
  96.                    HWND hParentWnd );            // Delete files in a Zip
  97. extern int  WINAPI ZipRepare( LPCSTR szZipFile, HWND hParentWnd );    // Recreate the Zip file
  98. extern int  WINAPI ZipSetComment( LPCSTR szZipFile, LPCSTR szComment, 
  99.                   HWND hParentWnd );            // Set the Zip Comment
  100.                   
  101.  
  102. /* Helpers */
  103. extern BOOL WINAPI ZipSetLanguage( UINT cZipLanguage );            // Set the Language
  104. extern int  WINAPI ZipGetReplaceFlag( void );                // Return the current overwrite mode
  105. extern BOOL WINAPI ZipSetReplaceText( LPCSTR szDialogTitle, 
  106.                    LPCSTR szDialogText, LPCSTR szYesBtn, 
  107.                    LPCSTR szNoBtn, LPCSTR szAlwaysBtn, 
  108.                    LPCSTR szNeverBtn );                    // Set the replace dialog box labels, used with 
  109.                                                // the LANGUAGE_NONE mode and the ZN_REPLACE notification message..
  110.  
  111. /* New routines */
  112. #define ZMODE_NORMAL    0
  113. #define ZMODE_FAST    1
  114. #define ZMODE_SLOW    2
  115. #define ZMODE_STORE    3
  116. extern BOOL WINAPI ZipSetMode( int zMode );        // [2.0] Specify the compression method (ZMODE_..)
  117. extern void WINAPI ZipCancel( BOOL bCancel );        // [2.0] Stop the current Zip action ASAP
  118.  
  119.  
  120. /* Split [2.0] */
  121. extern int WINAPI ZipSplit( HWND hParent, LPCSTR szZipName, LPCSTR szDestDir, long lFirstSize, long lNextSize, BOOL bDiskettePause, LPCSTR szTitle, LPCSTR szMsg );   // [2.0] Split an existing Zip file 
  122.  
  123. #define SPLIT_OK        0    // ZipSplit result [2.0]
  124. #define SPLIT_NOFILE        1
  125. #define SPLIT_NOMEM        2
  126. #define SPLIT_IOERROR        3
  127. #define SPLIT_TOOBIG        4
  128. #define SPLIT_ACCESSDENIED    5
  129. #define SPLIT_USERABORT        6
  130. #define SPLIT_FILETOOSMALL    7
  131.         
  132. #define ZN_SPLITTING    WM_USER + 61      // Splitting in process, wp = size (kb), lp = piece name [2.0]
  133. #define ZN_SPLITTED    WM_USER + 62      // A zip part is done, wp = part number,  lp = size ( in bytes ) [2.0]
  134.  
  135.  
  136.  
  137. #endif // _GOZIP
  138.  
  139.  
  140. #ifdef _GOUNZIP    
  141. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  142. //
  143. //        UnZip functions
  144. //
  145. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  146.  
  147.  
  148. /* Initialisation function */
  149. extern void WINAPI UnzipInit( LPCSTR szYourName, LPCSTR szPassword );    // required, if you are not a registered user szYourName = "TEST"
  150.  
  151.  
  152. /* Interface constants */
  153. #ifndef LANGUAGE_FRENCH
  154.     #define LANGUAGE_FRENCH        0    // french language will be used in the replace dialog box
  155. #endif
  156. #ifndef LANGUAGE_ENGLISH
  157.     #define LANGUAGE_ENGLISH    1    // English language will be used in the replace dialog box ( default )
  158. #endif
  159. #ifndef LANGUAGE_GERMAN
  160.     #define LANGUAGE_GERMAN        2    // German mode
  161. #endif
  162. #ifndef LANGUAGE_NONE
  163.     #define LANGUAGE_NONE        3    // No language (used with ZN_REPLACE)
  164. #endif
  165.  
  166.  
  167. /* Interface setting functions */
  168. extern BOOL WINAPI UnzipSetMsgBoxTitle( LPCSTR szNewTitle );    // Set the replace dialog box title ( default = "Replace...");
  169. extern void WINAPI UnzipSetLanguage( UINT iLanguage );        // Set the language for the replace dialog box
  170. extern BOOL WINAPI UnzipSetReceivingWindow( HWND hWnd );    // Set the window for notification messages
  171. extern void WINAPI UnzipSetBackgroundMode( BOOL bBackGroundMode );    // if TRUE, activate the multitask mode ( default )
  172. extern BOOL WINAPI UnzipSetReplaceText( LPCSTR szDialogTitle, 
  173.                    LPCSTR szDialogText, LPCSTR szYesBtn, 
  174.                    LPCSTR szNoBtn, LPCSTR szAlwaysBtn, 
  175.                    LPCSTR szNeverBtn );                    // Set the replace dialog box labels, used with 
  176.                                                // the LANGUAGE_NONE mode and the ZN_REPLACE notification message..
  177.  
  178.  
  179. /* Zip method constants */
  180. #define        ZMETHOD_STORED        0
  181. #define        ZMETHOD_SHRUNK        1
  182. #define        ZMETHOD_REDUCE1        2
  183. #define        ZMETHOD_REDUCE2        3
  184. #define        ZMETHOD_REDUCE3        4
  185. #define        ZMETHOD_REDUCE4        5
  186. #define        ZMETHOD_IMPLODE        6
  187. #define        ZMETHOD_TOKEN        7
  188. #define        ZMETHOD_DEFLATE        8
  189. #define        ZMETHOD_UNKNOWN        9
  190. #define        ZMETHOD_ERROR        10
  191.  
  192.  
  193. /* Information functions ( Zip ) */
  194. extern BOOL WINAPI IsFileInZip( LPCSTR szZIPFileName, LPCSTR szFileName);        // Return TRUE if the file is in the ZIP file
  195. extern int WINAPI CountFileInZip( LPCSTR szFileName );                    // Return number of files in this Zip File
  196. extern LPSTR WINAPI GetFileNameFromZIP( LPCSTR szFileName, UINT iFileNumber );        // Return the name of the iFileNumber file in this Zip File
  197. extern long WINAPI GetZFileOriginalSize( LPCSTR szZIPFileName, LPCSTR szFileName );    // Return the not compressed size of szFileName in octets.
  198. extern long WINAPI GetZFileCompressedSize( LPCSTR szZIPFileName, LPCSTR szFileName );    // Return the compressed size of szFileName in octets.
  199. extern LPSTR WINAPI GetZFileDate( LPCSTR szZIPFileName, LPCSTR szFileName );        // Return the date of a file in a Zip
  200. extern LPSTR WINAPI GetZFileTime( LPCSTR szZIPFileName, LPCSTR szFileName );        // Return the time of a file in a Zip
  201. extern UINT WINAPI GetZCompressMethod( LPCSTR szZipFileName, LPCSTR szFileName );    // Return the Zip method for a file ( ZMETHOD_* )
  202. extern BOOL WINAPI GetZFullInfos( LPCSTR szZipFileName, LPCSTR szFileName, LPSTR szResult );    // Fill <szResult> with all informations
  203. extern BOOL WINAPI GetZFileIsDir( LPCSTR szZIPFileName, LPCSTR szFileName );            // TRUE is the file is a directory specification
  204. extern BOOL WINAPI GetZFileIsEncrypted( LPCSTR szZIPFileName, LPCSTR szFileName );        // TRUE if the file is encrypted [2.0]
  205. extern BOOL WINAPI IsThisFileAZipFile( LPCSTR szFileName, BOOL bQuickTest );        // return TRUE if this file seems to be a zip file [2.0]
  206. extern BOOL WINAPI IsFileUnzipable( LPCSTR szFileName );                // return TRUE if this file name can be reproduce under DOS
  207. extern UINT WINAPI GetZipCommentLength( LPCSTR szFileName );                // return the size of the zip file comment in octets
  208. extern BOOL WINAPI GetZipComment( LPCSTR szFileName, LPSTR szBuffer );            // Put the zip comment in buffer
  209.  
  210.  
  211. /* Information functions ( General ) */
  212. extern BOOL WINAPI bDoesFileExist( LPCSTR szFileName );                // True if this file exists
  213. extern LPSTR WINAPI GetShortFileName( LPCSTR szFileName );            // Return filename without any path
  214. extern LPSTR WINAPI GetPathFromFileName( LPCSTR szFileName );            // Return the path without the file name
  215. extern BOOL WINAPI IsFileNameInFilter( LPCSTR szFileName, LPCSTR szMask );    // Return TRUE if filename is in specified filter
  216.  
  217.  
  218. /* Extraction function result constants */
  219. #define ZEXTRACT_OK            0
  220. #define ZEXTRACT_INTERNALERROR        1
  221. #define ZEXTRACT_FILENOTFOUND        2
  222. #define ZEXTRACT_CORRUPTED        3
  223. #define ZEXTRACT_EMPTY            4
  224. #define ZEXTRACT_ERRORINZIPFILE        5
  225. #define ZEXTRACT_NOMEM            6
  226. #define ZEXTRACT_DISKFULL        8
  227. #define ZEXTRACT_WARNING        10
  228.  
  229.  
  230. /* Helper constants */
  231. #define OVERWRITE_FALSE            0
  232. #define OVERWRITE_TRUE            1
  233. #define OVERWRITE_QUERY            2
  234. #define CREATEDIR_FALSE            0
  235. #define CREATEDIR_TRUE            1
  236.  
  237.  
  238. /* Extraction functions */                                        
  239. extern UINT WINAPI ExtractZipFiles( LPCSTR szFileName, LPCSTR szMask, LPCSTR szDestDir, UINT bOverwrite, BOOL bCreateDir );
  240. extern int WINAPI GetQueryFlag( void );        // Return the overwrite mode the user asked for
  241.  
  242.  
  243. /* Notification messages for UNZIP and VIEW*/
  244. #define ZN_OPENFILE        WM_USER + 38        // Open a file, WP = TRUE if Ok, LP = filename
  245. #define ZN_EXPANDING        WM_USER + 39        // Unzipping a file, WP = file current rate, LP = filename
  246. #define ZN_CLOSEFILE        WM_USER + 40        // Close a file, WP = TRUE if Ok, LP = filename
  247. #ifndef ZN_REPLACE
  248.     #define ZN_REPLACE    WM_USER +53        // The replace dialog box is opened ** NEW! **
  249. #endif
  250. #define ZN_NEWPASSWORD         WM_USER + 65           // A new password is required, WP= 0, LP = filename + tab key + current password [2.0]
  251. #define ZN_TEST                    WM_USER + 69        // Send by IsThisFile..., WP = TRUE if ok, LP = tested file name [2.0]
  252.  
  253. /* View function */
  254. extern BOOL WINAPI ViewFileFromZip( LPCSTR szZipFile, LPCSTR szMask, BOOL bTextOnly );    // view one or several files in a Zip
  255.  
  256.  
  257. /* ZIP files list [2.0]*/
  258.  
  259. typedef struct TAGZIPITEM        // A Zip file item [2.0]
  260.         {
  261.         char szName[50];     // The file name without any path
  262.         char szDir[260];    // The relative directory
  263.         BOOL bIsDir;        // TRUE if this item specifies a directory
  264.         BOOL bIsEncrypted;    // TRUE if this item is encrypted
  265.         int iMethod;        // The compression method
  266.         int iDay;        // Date: The Day
  267.         int iMonth;        // Date: The month
  268.         int iYear;        // Date: The year (no century specification)
  269.         int iHour;        // Time: The hour
  270.         int iMin;        // Time: The minutes
  271.         long lOriginalSize;    // The original size in bytes
  272.         int iRate;        // The compression rate
  273.         } ZIPITEM;
  274.                        
  275. #define ZSORT_BYFULLNAME    0    // The files list sort method [2.0]
  276. #define ZSORT_BYNAME        1
  277. #define ZSORT_BYDIR        2
  278. #define ZSORT_BYDATE        3
  279. #define ZSORT_BYSIZE        4
  280. #define ZSORT_BYRATE        5
  281. #define ZSORT_NONE        6
  282.         
  283. extern int WINAPI  GetZList( LPCSTR szZipName, register HWND hListWnd, unsigned int iFrom, int iSortMode, BOOL bBackGnd );      // Build the files list
  284. extern BOOL WINAPI GetZipItem( register HWND hListWnd, int iIndex, ZIPITEM FAR* zItem );                    // Retrive an item from this list
  285. extern BOOL WINAPI UnzipSortZList( register HWND hListWnd, int iSortMode, BOOL bBackGnd );                    // Sort the list again
  286.         
  287.  
  288. /* New routines [2.0] */
  289. extern BOOL WINAPI UnzipSetPassword( LPCSTR szPassword );    // Specify the password to use to extract the encrypted file(s) [2.0]
  290. extern void WINAPI SetAskPassword( BOOL bAsk );            // TRUE if you want Zip Studio asks the user for a password [2.0]
  291. extern BOOL WINAPI UnzipSetPasswordText( LPCSTR szDialogTitle, 
  292.     LPCSTR szDialogText, LPCSTR szPasswordLabel, LPCSTR szYesBtn, LPCSTR szNoBtn, LPCSTR szNeverBtn );                    
  293.                                 // Set the password dialog box labels, used with ZN_NEWPASSWORD [2.0]
  294. extern void WINAPI UnzipCancel( BOOL bCancel );            // Set or Reset the Cancel flag for the UNZIP process:
  295.                                 // You must reset this flag before you call any UNZIP function:
  296.                                 // (eg UnzipCancel(FALSE) ... ) [2.0]
  297.  
  298. /* Join function [2.0] */
  299. extern int WINAPI ZipJoin( HWND hParent, LPCSTR szName, LPCSTR szDestDir, BOOL bSendMsg, LPCSTR szTitle, LPCSTR szMsg );    // Join a splitted Zip file [2.0]
  300.                                 
  301. #define JOIN_OK            0    // ZipJoin result code [2.0]
  302. #define JOIN_NOFILE        1
  303. #define JOIN_NOMEM        2
  304. #define JOIN_IOERROR        3
  305. #define JOIN_ACCESSDENIED    4
  306. #define JOIN_USERABORT        5
  307. #define JOIN_NOTASPLITTEDFILE     7
  308. #define JOIN_ZIPEXIST        8
  309.         
  310. #define ZN_JOINING    WM_USER + 41     // Split in process, wp = size in Kbytes, lp = file name
  311. #define ZN_JOINED    WM_USER + 42    // A zip part is done, wp = part number,  lp = size ( in bytes )
  312. #define ZN_JOINDONESIZE    WM_USER + 43     // Split is done for all the ZIP files, lp = total size in bytes
  313. #define ZN_JOINDONENAME    WM_USER + 44     // Split is done for all the ZIP files, lp = zip name
  314.  
  315.  
  316. #endif // _GOUNZIP
  317.  
  318. #ifdef __cplusplus
  319.     }
  320. #endif
  321.  
  322.  
  323. /* ---------------------------------------- End of file ------------------------------------------*/
  324. #endif
  325.             
  326.